<template>
    <div id="center-bar" style="width: 100%; height: 450px"></div>
</template>
<script lang="ts">
import { defineComponent, onMounted } from 'vue'

import echarts, { option } from './constant'
import { result } from '../../constant'

export default defineComponent({
    name: 'CenterBar',
    setup() {
        const constant = {
            option
        }
        onMounted(() => {
            constant.option.xAxis.data = result.map((item: any) => item.countyName)
            let data = result.map((item: any) => item.totalSales)
            constant.option.series[2].data = data

            echarts.init(document.getElementById('center-bar')).setOption(constant.option)
        })
        return {
            ...constant
        }
    }
})
</script>
